package com.tm.seurity.handler;

import com.tm.result.Result;
import com.tm.result.ResultCode;
import com.tm.utils.ResponseUtil;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by lichuan on 2022-09-24.
 */
@Component
public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
        //TODO 用于处理无权限访问异常的类
        System.out.println("用于处理无权限访问异常的类");
        ResponseUtil.out(httpServletResponse, Result.error(ResultCode.MEIYOUQUANXIAN));
    }
}
